//修改此处后需要重新启动
import { defineStore } from 'pinia';
import { computed, ref } from 'vue';
export const userStore = defineStore('userStore', () => {
	// state 变量声明为state
	const id = ref(0)
	const username = ref("")
	const pname =ref("")
	const levelId = ref(0)
	const pid = ref(0)
	const name = ref("")
	const pnum = ref("")
	
	// getters 计算属性为getters
	const get_use_info = computed(() => {
		return {
			username:username.value,
			levelId:levelId.value,
			pid:pid.value,
			id:id.value,
			pname:pname.value,
			name:name.value,
			pnum:pnum.value,

		};
	});
	// actions 函数为actions
	const save_user_info = (params) => {
		id.value = params.id
		levelId.value = params.levelId
		pid.value = params.pid
		name.value = params.name
		username.value = params.username
		pname.value = params.pname
		pnum.value = params.pnum;
	}
	//暴露两个函数
	return {id,username,pname,levelId,pid,name,pnum,get_use_info,save_user_info}
},{
	//持久化
	persist:{
		enable:true,
		key:"user",
		storage:sessionStorage,
	}
}
);
